package org.example.font.service.impl;


import org.example.font.mapper.ReportMapper;
import org.example.font.model.EmpPostData;
import org.example.font.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;
    @Override
    public List<Map> getEmpGenderData() {
        return reportMapper.getEmpGenderData();
    }

    @Override
    public EmpPostData getEmpPostData() {
        List<Map> res = reportMapper.getEmpPostData();
        List<Object> empList = res.stream().map(data -> data.get("name")).toList();
        List<Object> countList = res.stream().map(data -> data.get("count")).toList();
        EmpPostData empPostData = new EmpPostData();
        empPostData.setEmpList(empList);
        empPostData.setCount(countList);
        return empPostData;
    }
}
